/**
 * 
 */
package hawk.example.juni5.testkit;

import static org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod;
import static org.junit.platform.testkit.engine.EventConditions.event;
import static org.junit.platform.testkit.engine.EventConditions.skippedWithReason;
import static org.junit.platform.testkit.engine.EventConditions.test;

import org.junit.jupiter.api.Test;
import org.junit.platform.testkit.engine.EngineTestKit;
import org.junit.platform.testkit.engine.Events;

/**
 * @author Hawk
 *
 */
public class EngineTestKitSkippedMethodDemo {
	
	@Test
	void verifyJupiterMethodWasSkipped() {
		String methodName = "skippedTest";

		Events testEvents = EngineTestKit//
				.engine("junit-jupiter") // Select the JUnit Jupiter TestEngine.
				.selectors(selectMethod(ExampleTestCase.class, methodName)) // Select the skippedTest() method in the ExampleTestCase test class.
				.execute() // Execute the TestPlan.
				.testEvents(); // Filter by test events.

		testEvents.assertStatistics(stats -> stats.skipped(1)); // Optionally assert the expected statistics.

		testEvents //
				.assertThatEvents() // Assert that the recorded test events contain exactly one skipped test named skippedTest
									// with "for demonstration purposes" as the reason.
				.haveExactly(1, event(test(methodName), skippedWithReason("for demonstration purposes")));
	}
}
